LAGOS Analysis

Loading in data

First download and then specifically grab the locus (or site lat longs)

# #Lagos download script
#LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())


#Load in lagos
lagos <- lagosne_load()
## Warning in (function (version = NULL, fpath = NA) : LAGOSNE version unspecified,
## loading version: 1.087.3
#Grab the lake centroid info
lake_centers <- lagos$locus

Convert to spatial data

#Look at the column names
#names(lake_centers)

#Look at the structure
#str(lake_centers)

#View the full dataset
#View(lake_centers %>% slice(1:100))

spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
                          crs=4326) %>%
  st_transform(2163)

#Subset for plotting
subset_spatial <- spatial_lakes %>%
  slice(1:100) 

subset_baser <- spatial_lakes[1:100,]

#Dynamic mapviewer
mapview(subset_spatial)

Subset to only Minnesota

states <- us_states()

#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
  filter(name == 'Minnesota') %>%
  st_transform(2163)

#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]

#Plotting the first 1000 lakes
minnesota_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

In-Class work

1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)

#mapview(states)
Icombined <- states %>%
  filter(name %in% c('Illinois', 'Iowa')) %>%
  st_transform(2163)

I_lakes <- spatial_lakes[Icombined,]

#Iowa
Iowa <- states %>%
  filter(name == 'Iowa') %>%
  st_transform(2163)

#Illinois
Illinois <- states %>%
  filter(name == 'Illinois') %>%
  st_transform(2163)

#rbind states
IA_IL<-rbind(Iowa,Illinois)
mapview(IA_IL)

2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa combined? How does this compare to Minnesota?

illinois_lakes <- spatial_lakes[Illinois,]
iowa_lakes <- spatial_lakes[Iowa,]

#rbind lake data
IA_IL2<-rbind(iowa_lakes, illinois_lakes)

#count
str(IA_IL2$lagoslakeid)
##  int [1:16466] 4280 4285 4292 4312 4314 4322 4351 4363 4389 4393 ...
str(minnesota_lakes$lagoslakeid)
##  int [1:29038] 59 60 61 62 63 64 67 68 71 72 ...

There are about twice as many lakes in Minnesota, 29038, as there are in Iowa and Illinois combined, 16466.

3) What is the distribution of lake size in Iowa vs. Minnesota?

  • Here I want to see a histogram plot with lake size on x-axis and frequency on y axis (check out geom_histogram)
ggplot(iowa_lakes, aes(x=lake_area_ha))+
  geom_histogram()+
  scale_x_log10()+
  labs(title = "Iowa",
    x="log(lake area(ha))")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(minnesota_lakes, aes(x=lake_area_ha))+
  geom_histogram()+
  scale_x_log10()+
  labs(title = "Minnesota",
    x="log(lake area (ha))")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

There are more larger lakes in Minnesota than in Iowa where the lakes are much smaller.

4) Make an interactive plot of lakes in Iowa and Illinois and color them by lake area in hectares

I_lakes %>%
  arrange(-lake_area_ha) %>%
    slice(1:1000) %>%
  mapview(.,zcol = 'lake_area_ha')

5) What other data sources might we use to understand how reservoirs and natural lakes vary in size in these three states?

Using information such as the perimeter or the lake and lake depth would give another source of data to compare the sizes of the lakes.